<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@page import="com.tubeonfire.model.admin.AdvertisingModel"%>
<%@page import="com.tubeonfire.entity.Playlist"%>
<%@page import="com.tubeonfire.model.PlaylistModel"%>
<%@page import="com.tubeonfire.entity.Channel"%>
<%@page import="com.tubeonfire.model.ChannelModel"%>
<%@page import="com.tubeonfire.model.admin.SiteConfigModel"%>
<%@page import="com.tubeonfire.entity.SiteConfig"%>
<%@page import="com.tubeonfire.entity.Advertising"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%		
	SiteConfig siteConfig = SiteConfigModel.get();	
%>
<jsp:include page="/admin/elements/header.jsp">
	<jsp:param value="Advertising Manager" name="title"/>
</jsp:include>
<script type="text/javascript" src="/admin/js/mine/admin.js"></script>
<script type="text/javascript" src="/admin/js/mine/advertising_choose.js"></script>
	<body class="loggedin">
		<jsp:include page="/admin/elements/top.jsp"/>
	    <!-- START OF MAIN CONTENT -->
	    <div class="mainwrapper">
	     	<div class="mainwrapperinner">         	        
				<jsp:include page="/admin/elements/left.jsp">
					<jsp:param value="advertising" name="current_page"/>
				</jsp:include>					              	                   
	        	<div class="maincontent noright">
	        		<div class="maincontentinner">	            	
		                <ul class="maintabmenu">		                	
		                	<li class="current"><a href="/admin/advertising/manage?place=1">Home</a></li>
		                	<li><a href="/admin/advertising/manage?place=2">Detail</a></li>
		                	<li><a href="/admin/advertising/manage?place=3">Newest & Most View</a></li>
		                	<li><a href="/admin/advertising/manage?place=4">Playlist</a></li>
		                	<li><a href="/admin/advertising/manage?place=5">Channel</a></li>
		                	<li><a href="/admin/advertising/manage?place=6">Search & Tag</a></li>
		                	<li><a href="/admin/advertising/manage?place=7">All Playlist</a></li>
		                	<li><a href="/admin/advertising/manage?place=8">All Channel</a></li>		                	
		                </ul><!--maintabmenu-->	        		                        
	                	<div class="content">
	                	<div class="notification msginfo">		
	                		<a class="close"></a>				   
						    <p>Note : Only 3 Google Adsense Block can be added in one page. 4th advertising block will not be displayed.</p>
						</div>	  		
	                	<jsp:include page="/admin/elements/message.jsp"/>
	                	<div id="messageDiv" class="notification hidden">						   
						    <p></p>
						</div>											    						       
	                    	<div class="contenttitle">
	                    		<h2 class="image"><span>Choose Place To Add Advertising</span></h2>
	                    	</div>
	                    	<br />
		                    <section id="webLayout" class="homePage">
						            
					            <!-- slideshow -->
					            <img alt="" src="/admin/images/ads_header.jpg" width="100%">
					            
					            <!-- content - left side -->
					            <div class="left width-69">
					            	<%
						            	List<String> listColour = new ArrayList<String>();
						            	listColour.add("green");	
						            	listColour.add("yellow");	
						            	listColour.add("blue");
						            	listColour.add("pink");
						            	listColour.add("orange");	
					            		if(siteConfig.getHomePageDisplayObject()==2){
					            			ChannelModel cModel = new ChannelModel();			
					    					cModel.setLimit(siteConfig.getHomePageBlockQuantity());
					    					cModel.prepareList();	
					    					if(cModel.getListResult().size()>0){
					    						int colour = 0;
					    						int count = 1;
					    						for(Channel channel : cModel.getListResult()){
					            	%>								          								                								               
							            	<div class="roundBox">
						            			<h4 class="button <%=listColour.get(colour)%>"><%=channel.getTitle() %></h4>
						            			<img alt="" src="/admin/images/ads_tube_block_<%=colour %>.jpg" style="width: 100%">
						            		</div>
						            		<div class="advWrap adv-468x60">
						            			<div>
								            		<%
									                	Advertising ads = AdvertisingModel.getByPlaceAndPosition(1, count);									                
								            			if(ads!=null){
								            				%>
								            				<%=ads.getType()==1?"Google Adsense":"Advertising" %> Added&nbsp;
							            					<a href="/admin/advertising/edit?id=<%=ads.getId() %>" title="Edit Advertising">(Edit)</a>
							            					<a href="<%=ads.getId() %>" title="Remove Advertising" class="btnRemove">(Remove)</a>
								            				<%
								            			}else{
								            				%>
								            				<a href="/admin/advertising/add?place=1&position=<%=count %>" title="Add Advertising">(468x60) Click To Add Advertising</a>	
								            				<%
								            			}
								            		%>
						            			</div>
					            			</div>
					            	<%
					            					count++;
									            	if(colour==(listColour.size()-1)){
						                				colour=0;	
						                			}else{
						                				colour++;	
						                			}  
					    						}
					    					}
					            		}else{
					            			PlaylistModel plModel = new PlaylistModel();												
					                		plModel.setLimit(siteConfig.getHomePageBlockQuantity());
					                		plModel.prepareList(true);
					    					if(plModel.getListResult().size()>0){	
					    						int colour = 0;
					    						int count = 1;
					    						for(Playlist pl : plModel.getListResult()){
					            			%>						            			
							            	<div class="roundBox">
						            			<h4 class="button <%=listColour.get(colour)%>"><%=pl.getTitle() %></h4>
						            			<img alt="" src="/admin/images/ads_tube_block_<%=colour %>.jpg" style="width: 100%">
						            		</div>
						            		<div class="advWrap adv-468x60">
						            			<div>
							            			<%
									                	Advertising ads = AdvertisingModel.getByPlaceAndPosition(1, count);									                
								            			if(ads!=null){
								            				%>
								            				<%=ads.getType()==1?"Google Adsense":"Advertising" %> Added&nbsp;
							            					<a href="/admin/advertising/edit?id=<%=ads.getId() %>" title="Edit Advertising">(Edit)</a>
							            					<a href="<%=ads.getId() %>" title="Remove Advertising" class="btnRemove">(Remove)</a>
								            				<%
								            			}else{
								            				%>
								            				<a href="/admin/advertising/add?place=1&position=<%=count %>" title="Add Advertising">(468x60) Click To Add Advertising</a>	
								            				<%
								            			}
								            		%>
							            		</div>
					            			</div>
					            			<%
					            					count++;
							            			if(colour==(listColour.size()-1)){
						                				colour=0;	
						                			}else{
						                				colour++;	
						                			}   
					    						}
					    					}
					            		}
					            	%>
					            	
					                						               
					            </div>
					            
					            <!-- content - right side -->
					            <div class="right width-30">
					            	<div class="roundBox">
						            	<!-- click here to add your adv -->
						            	<div class="advWrap adv-250x250 clearafter">
						            		<div>
						            			<%
								                	Advertising ads = AdvertisingModel.getByPlaceAndPosition(1, 999);									                
							            			if(ads!=null){
							            				%>
							            				<%=ads.getType()==1?"Google Adsense":"Advertising" %> Added&nbsp;<br/>
							            				<a href="/admin/advertising/edit?id=<%=ads.getId() %>" title="Edit Advertising">(Edit)</a>
							            				<a href="<%=ads.getId() %>" title="Remove Advertising" class="btnRemove">(Remove)</a>
							            				<%
							            			}else{
							            				%>
							            				<a href="/admin/advertising/add?place=1&position=999" title="Add Advertising">(250x250)<br/> Click To Add Advertising</a>	
							            				<%
							            			}
							            		%>
						            		</div>
						                </div>
						                
						            	<div>
						            		<img alt="" src="/admin/images/ads_recent_view.jpg" width="100%">
						                </div>
						                
						                <!-- click here to add your adv -->
						            	<div class="advWrap adv-250x250 clearafter">
						            		<div>
						            			<%
						            				ads = AdvertisingModel.getByPlaceAndPosition(1, 998);									                
							            			if(ads!=null){
							            				%>
							            				<%=ads.getType()==1?"Google Adsense":"Advertising" %> Added&nbsp;<br/>
							            				<a href="/admin/advertising/edit?id=<%=ads.getId() %>" title="Edit Advertising">(Edit)</a>
							            				<a href="<%=ads.getId() %>" title="Remove Advertising" class="btnRemove">(Remove)</a>
							            				<%
							            			}else{
							            				%>
							            				<a href="/admin/advertising/add?place=1&position=998" title="Add Advertising">(250x250)<br/> Click To Add Advertising</a>	
							            				<%
							            			}
							            		%>
						            		</div>
						                </div>
						                
						                <div>
						            		<img alt="" src="/admin/images/ads_playlist.jpg" width="100%">
						                </div>
						                
						                <!-- click here to add your adv -->
						            	<div class="advWrap adv-250x250 clearafter">
						            		<div>
						            			<%
						            				ads = AdvertisingModel.getByPlaceAndPosition(1, 997);									                
							            			if(ads!=null){
							            				%>
							            				<%=ads.getType()==1?"Google Adsense":"Advertising" %> Added&nbsp;<br/>
							            				<a href="/admin/advertising/edit?id=<%=ads.getId() %>" title="Edit Advertising">(Edit)</a>
							            				<a href="<%=ads.getId() %>" title="Remove Advertising" class="btnRemove">(Remove)</a>
							            				<%
							            			}else{
							            				%>
							            				<a href="/admin/advertising/add?place=1&position=997" title="Add Advertising">(250x250)<br/> Click To Add Advertising</a>	
							            				<%
							            			}
							            		%>
						            		</div>
						                </div>
						                
						                <div>
						            		<img alt="" src="/admin/images/tags.jpg" width="100%">
						                </div>
						                
						                <!-- click here to add your adv -->
						            	<div class="advWrap adv-250x250 clearafter">
							            	<div>
						            			<%
						            				ads = AdvertisingModel.getByPlaceAndPosition(1, 996);									                
							            			if(ads!=null){
							            				%>
							            				&nbsp;<%=ads.getType()==1?"Google Adsense":"Advertising" %> Added&nbsp;<br/>
							            				<a href="/admin/advertising/edit?id=<%=ads.getId() %>" title="Edit Advertising">(Edit)</a>
							            				<a href="<%=ads.getId() %>" title="Remove Advertising" class="btnRemove">(Remove)</a>
							            				<%
							            			}else{
							            				%>
							            				<a href="/admin/advertising/add?place=1&position=996" title="Add Advertising">(250x250)<br/> Click To Add Advertising</a>	
							            				<%
							            			}
							            		%>
							                </div>
						                </div>
					                </div>
					            </div>
					            <div style="clear: both;"></div>
					            <!-- footer -->
					            <img alt="" src="/admin/images/footer.jpg" width="100%">
						    </section>       
	                    <br /><br />	                    
	                </div><!--content-->	                
	            </div><!--maincontentinner-->
				<jsp:include page="/admin/elements/bottom.jsp"></jsp:include>                    	           	
	        </div><!--maincontent-->	                        
	     	</div><!--mainwrapperinner-->
	    </div><!--mainwrapper-->
		<!-- END OF MAIN CONTENT -->    
	</body>
</html>
